package ArrayList;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: dch
 * @Date: 2020/6/9 9:03
 * @Description:  线程任务类
 */
public class CollectionTaskTest {
    public static void main(String[] args) throws InterruptedException {
        //创建集合
        List<String> list = new ArrayList<>();
        //创建线程任务
        CollectionTask collectionTask = new CollectionTask(list);
        //开启50个线程来执行线程任务
        for(int i=1;i<=50;i++){
            new Thread(collectionTask).start();
        }
        //休眠3秒
        Thread.sleep(3000);

        for(String str:list){
            System.out.println(str);
        }
        System.out.println("集合长度："+list.size());
    }
}
